<?php
/**
 * 	Bushido
 *
 * @category   Bushido
 * @packageBushido_Controller
 * @subpackage Action
 * @copyright  Copyright (c) 2008-2009 Nathan Keyes
 * @author Nathan Keyes
 * @version$Id: Theme.php 7 2009-11-14 22:42:08Z nkeyes $
 */
require_once 'Zend/Controller/Action.php'; 

class Bushido_Controller_Action_Theme extends Bushido_Controller_Action
{
	protected $_themes = array
	(
		'default' => array
		(
			'main_color' => array
			(
				'r' => 0,
				'g' => 69,
				'b' => 123
			),
			'app_icon' => 'pr.png'
		)
	);
	
	public function init()
	{
		//Zend_Session::rememberMe(60*30);
		
		parent::init();
		$this->_requiresAuth = false;
		$this->_helper->contextSwitch()->addContext
		(
			'css',
			array
			(
				'headers' => array
				(
					'Content-Type' => 'text/css'
				),
				'callbacks' => array
				(
					'init' => array($this, 'initCallback')
				)
			)
		)
		->addActionContext('css', array('css'));
	}
	
	public function initCallback()
	{
		$this->_helper->layout->disableLayout();
	}
	/**
	 * 
	 * @return void
	 */
	public function indexAction() 
	{
	} 
	
	/**
	 * 
	 * @return void
	 */
	public function cssAction()
	{
		$this->_setupTheme();
	}
	
	
	protected function _setupTheme()
	{
		$this->_helper->contextSwitch()->initContext('css');
		$themeName = $this->_getParam('theme', 'default');
		$theme = $this->_themes[$themeName];
		$main_color = $theme['main_color'];
	
		
		$theme['triad'] = Bushido_ColorPalette::triad($main_color);
		$theme['analogues'] = Bushido_ColorPalette::analogues($main_color);
		$theme['splitCompliments'] = Bushido_ColorPalette::split_compliments($main_color);
		$theme['compliment'] = Bushido_ColorPalette::compliment($main_color); 
		
		//$theme['main_color_light'] = $splitCompliments['minusColor'];
		//$theme['main_color_light'] = $splitCompliments['plusColor'];
		$theme['main_color_light'] = Bushido_ColorPalette::lightenColor($main_color, 40);
		//$theme['main_color_light'] = Bushido_ColorPalette::darkenColor($main_color, 30);

		
		$this->view->theme = $theme;
	}
	
}